import {View} from '@tarojs/components'
import {CSSProperties} from 'react'

export const CCard: React.FC<{
  title?: JSX.Element
  titleSplitLine?: boolean
  style?: CSSProperties
  onClick?: () => void
}> = ({
  children,
  title,
  titleSplitLine = false,
  style,
  onClick
}): JSX.Element => {
  return (
    <View
      className="w-full rounded-card overflow-hidden"
      style={Object.assign(
        {
          padding: '32rpx',
          backgroundColor: '#fff'
        },
        style
      )}
      onClick={() => onClick && onClick()}
    >
      {/* 标题栏 */}
      {title}
      {/* 分割线 */}
      {titleSplitLine ? (
        <View className="w-full h-1 m-0 p-0 bg-x_line"></View>
      ) : null}
      {/* 内容 */}
      {children}
    </View>
  )
}
